/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Charles & Jacob
 */

import java.sql.*;

public class ClientBrowser {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stmt;
        ResultSet rs = null;
        
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
        } catch (ClassNotFoundException E) {
            System.err.println("Unable to load driver.");
            E.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    String dbURL = "jdbc:mysql://db.luther.edu/DairyDatabase";
    String userName = "bantch01";
    String pword = "";
    
    try {
        conn = DriverManager.getConnection(dbURL,userName,pword);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    
    try {
        stmt = conn.createStatement();
        rs = stmt.executeQuery("select ClientNum, Name from Client");
        while (rs.next()) {
            ResultSetMetaData rsmd = rs.getMetaData();
            System.out.println(rsmd.getColumnName(1)+":"+rsmd.getColumnLabel(1));
            Integer id = rs.getInt(1);
            String name = rs.getString(2);
            System.out.println(id + " : " + name);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    }
    
    
}
